import http from '@/utils/http'

const BASE_URL = '/card/wechatUser'

export interface WechatUserResp {
  id: string
  openId: string
  nickname: string
  avatar: string
  gender: string
  country: string
  province: string
  city: string
  userName: string
  createTime: string
  createUser: string
  updateTime: string
  updateUser: string
  createUserString: string
  updateUserString: string
}
export interface WechatUserDetailResp {
  id: string
  openId: string
  nickname: string
  avatar: string
  gender: string
  country: string
  province: string
  city: string
  userName: string
  createTime: string
  createUser: string
  updateTime: string
  updateUser: string
  createUserString: string
  updateUserString: string
}
export interface WechatUserQuery {
  nickname: string,
  queryType: number | string,
  sort: Array<string>
}
export interface WechatUserPageQuery extends WechatUserQuery, PageQuery { }

/** @desc 查询微信用户列表 */
export function listWechatUser(query: WechatUserPageQuery) {
  return http.get<PageRes<WechatUserResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询微信用户详情 */
export function getWechatUser(id: string) {
  return http.get<WechatUserDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增微信用户 */
export function addWechatUser(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改微信用户 */
export function updateWechatUser(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除微信用户 */
export function deleteWechatUser(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出微信用户 */
export function exportWechatUser(query: WechatUserQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
